<template>
  <el-dialog :title="'积分明细'" :close-on-click-modal="false" :visible.sync="visible">
    <el-table :data="dataList" border v-loading="dataListLoading"
      style="width: 100%">
      <el-table-column prop="updateTime" header-align="center" align="center" label="序号">
        <template slot-scope="scope">
          <div v-if="scope.row">
            {{ scope.$index+1 }}
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="updateTime" header-align="center" align="center" label="日期">
        <template slot-scope="scope">
          <div v-if="scope.row">
            {{ getStrTime(scope.row.createTime) }}
          </div>
        </template>
      </el-table-column>
      
      <el-table-column prop="score" header-align="center" align="center" label="积分变化">
      </el-table-column>
      <el-table-column prop="remark" header-align="center" align="center" label="备注">
      </el-table-column>
    </el-table>
    <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
    <span slot="footer" class="dialog-footer">
      <!-- <el-button type="primary" @click="dataFormSubmit()">保存</el-button> -->
      <el-button @click="visible = false">关闭</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  data () {
    return {
      pageIndex:1,
      totalPage:0,
      dataList:[],
      pageSize:10,
      dataListLoading:false,
      uploadVisible: false,
      visible: false,
      dataForm: {
        id: 0,
      },
      dataRule: {
        // nickName: [
        //   { required: true, message: '请输入昵称', trigger: 'blur' }
        // ],
        // deleted: [
        //   { required: true, message: '逻辑删除： 0 正常 1 逻辑删除不能为空', trigger: 'blur' }
        // ],
        // createTime: [
        //   { required: true, message: '创建时间不能为空', trigger: 'blur' }
        // ],
        // updateTime: [
        //   { required: true, message: '修改时间不能为空', trigger: 'blur' }
        // ]
      }
    }
  },
  methods: {
    getDataList(id) {
      this.$http({
        url: this.$http.adornUrl(`/admin/user/score/record/page`),
        method: 'post',
        data: this.$http.adornData({
          pageNum: this.pageIndex,
          pageSize: this.pageSize,
          id: this.dataForm.id,
        })
      }).then(({ data }) => {
        if (data && data.code === '200') {
          this.dataList = data.list
          this.totalPage = data.total
        } else {
          this.dataList = []
          this.totalPage = 0
        }
        this.dataListLoading = false
      })
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val
      this.pageIndex = 1
      this.getDataList()
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val
      this.getDataList()
    },
    init (id) {
      this.dataForm.id =id
      this.getDataList()
      // this.dataForm.memberId = Number(id) || 0
      this.visible = true
      // this.$nextTick(() => {
      //   this.$refs['dataForm'].resetFields()
      //   if (this.dataForm.memberId) {
      //     this.$http({
      //       url: this.$http.adornUrl(
      //         `/admin/member/getMemberInfo?memberId=${this.dataForm.memberId}`
      //       ),
      //       method: 'get',
      //       params: this.$http.adornParams()
      //     }).then(({ data }) => {
      //       if (data && data.code === '200') {
      //         this.dataForm.tel = data.data.tel
      //         this.dataForm.nickName = data.data.nickName
      //         this.dataForm.remark = data.data.remark
      //         this.dataForm.gender = data.data.gender
      //         this.dataForm.birthday = data.data.birthday
      //         this.dataForm.name = data.data.name
      //         this.dataForm.addressList = data.data.addressList
      //       }
      //     })
      //   }
      // })
    },
  }
}
</script>
<style lang="scss" scoped>
.addres {
  padding-bottom: 12px;
  border-bottom: 1px solid #ccc;

  .top {
    display: flex;

    .tel {
      margin-left: 10px;
    }
  }

  .bottom {}
}
</style>
